﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Windows.Forms;
using static BankSimulation.ATM;

namespace BankSimulation
{
    internal class Bank
    {
        // 银行名称
        public string Name { get; set; }

        public Bank(string name)
        {
            Name = name;
        }

        // ATM机对象
        public ATM ATM { get; set; }
        public Dictionary<int, Account> accounts = new Dictionary<int, Account>();

        // 索引器，通过账号检索账户
        public Account this[int accountNumber]
        {
            get
            {
                if (accounts.ContainsKey(accountNumber))
                {
                    return accounts[accountNumber];
                }
                else
                {
                    return null; // 如果没有匹配的账户，返回null
                }
            }
        }

        // 添加账户到银行
        public void AddAccount(Account account)
        {
            accounts[account.AccountNumber] = account;
        }

    }



}
